package com.example.demo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;

import java.util.Date;

public abstract class AbstractLogAspect {

    public AbstractLogAspect() {
    }

    @Around("pointcut()")
    public Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        // 记录方法开始执行时间
        long beginTime = new Date().getTime();
        // 调用原始方法
        Object proceed = proceedingJoinPoint.proceed();
        // 记录方法执行结束时间
        long endTime = new Date().getTime();
        // 处理方法
        dealMethod(proceedingJoinPoint, endTime - beginTime);
        // 返回原始方法的执行结果
        return proceed;
    }

    public abstract void dealMethod(ProceedingJoinPoint proceedingJoinPoint, long l);
}
